<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script src="./js/common.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="./js/html5.min.js"></script>
    <script src="./js/respond.min.js"></script>
    <![endif]-->
    <script>
        var baseUrl = parent.baseUrl;
        var env = $.getUrlParam("env");
        var gateway = $.getUrlParam("gateway");
        var likeComment = $.getUrlParam("likeComment");
        if (!likeComment) {
            likeComment = "";
        } else {
            likeComment = encodeURI(likeComment);
        }
        $(function () {
            $("#l_like_comment").val(decodeURI(decodeURI(likeComment)));
        });
    </script>
</head>

<body class="layui-anim layui-anim-up">
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">告警配置</a>
        <a>
          <cite>服务组告警配置</cite>
        </a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input id="l_like_comment" type="text" name="likeComment" placeholder="请输入备注" autocomplete="off"
                   class="layui-input"/>
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th>组ID</th>
            <th>备注</th>
            <th>创建时间</th>
            <th>状态</th>
            <th>告警人配置</th>
        </tr>
        </thead>
        <tbody id="routeServiceListView">

        </tbody>
    </table>

</div>
<script>
    function openAlertServcieGroupSetting(id) {
        var spanId = '<span style="color: green;">' + id + '</span>';
        x_admin_show(spanId + '-告警人配置', './alert-service-group-user-list.html?env=' + env + "&gateway=" + gateway + "&id=" + id);
    }
</script>

<script>
    layui.use(['laytpl', 'layer'], function () {
        var laytpl = layui.laytpl;
        var layer = layui.layer;

        var likeComment = $.getUrlParam("likeComment");
        if (!likeComment) {
            likeComment = "";
        } else {
            likeComment = encodeURI(likeComment);
        }

        $.ajax({
            url: baseUrl + "/servcieGateway/routeService/list?likeComment=" + likeComment + "&env=" + env + "&gateway=" + gateway + "&applicationName=" + gateway,
            data: "",
            contentType: 'application/json;charset=utf-8',
            dataType: "JSON",
            // async: false,
            type: "GET",
            timeout: 10000,
            success: function (respData) {
                if (respData.respCode === '0000') {
                    var data = {
                        "list": respData.data.items
                    };

                    var getTpl = routeServiceListViewScript.innerHTML
                        , view = document.getElementById('routeServiceListView');
                    laytpl(getTpl).render(data, function (html) {
                        view.innerHTML = html;
                    });
                } else {
                    layer.msg(respData.respDesc, {
                        icon: 2,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        //do something
                    });
                }
            }
        });
    });
</script>

<script id="routeServiceListViewScript" type="text/html">
    {{# layui.each(d.list, function(index, item){ }}

    <tr>
        <td>{{ item.id }}</td>
        <td>{{ item.comment }}</td>
        <td>{{ item.createTime }}</td>

        {{# if(item.statusCode === 0){ }}
        <td class="td-status">
            <span class="layui-btn layui-btn-disabled layui-btn-sm">{{ item.statusDesc }}</span>
        </td>
        {{# } }}


        {{# if(item.statusCode === 1){ }}
        <td class="td-status">
            <span class="layui-btn layui-btn-normal layui-btn-sm">{{ item.statusDesc }}</span>
        </td>
        {{# } }}


        {{# if(item.alertUsers.length === 0){ }}
        <td>
            <span class="layui-btn layui-btn-primary layui-btn-sm"
                  onclick="openAlertServcieGroupSetting('{{ item.id }}')"><i
                    class="layui-icon layui-icon-set-sm">&#xe620;</i>设置
            </span>
        </td>
        {{# } }}

        {{# if(item.alertUsers.length > 0){ }}
        <td>
            <span class="layui-btn layui-btn-normal layui-btn-sm"
                  onclick="openAlertServcieGroupSetting('{{ item.id }}')"><i
                    class="layui-icon layui-icon-set-sm">&#xe60b;</i>详情</span>
        </td>
        {{# } }}
    </tr>

    {{# }); }}
</script>


<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //监听提交
        form.on('submit(sreach)', function (data) {
            var likeComment = $.trim(data.field.likeComment);
            if (likeComment) {
                likeComment = encodeURI(encodeURI(likeComment));
            }

            var url = "./alert-service-group-list.html?likeComment=" + likeComment + "&env=" + env + "&gateway=" + gateway + "&applicationName=" + gateway;
            window.location.href = url;
            return false;
        });

    });
</script>

<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>